<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2023/3/11
  Time: 14:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--引入jQuery--%>
<script src="/webjars/jquery/3.6.0/jquery.min.js"></script>
<%--引入bootstrap--%>
<link rel="stylesheet" href="/webjars/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="/webjars/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<html>
<style>
    .table{
        text-align: center;
    }
</style>
<script>
    //点击超链接跳转到对应页面
    function skinPage(v) {
        //为表单隐藏域赋值
        $("#page").val(v)
        // 提交表单
        document.forms[0].submit()
    }
</script>
<head>
    <title>Title</title>
</head>
<body>
    <div class="container">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">
                <h3>学生信息</h3>
            </h3>
        </div>
            <table class="table table-striped table-hover">
                <tr>
                    <td>学号</td>
                    <td>姓名</td>
                    <td>班级</td>
                    <td>年龄</td>
                    <td>分数</td>
                    <td>性别</td>
                    <td>住址</td>
                    <td>操作</td>
                </tr>
                <c:forEach var="st" items="${pr.rows}">
                <tr>
                    <td>${st.sid}</td>
                    <td>${st.sname}</td>
                    <td>${st.cname}</td>
                    <td>${st.age}</td>
                    <td>${st.score}</td>
                    <td>${st.sex}</td>
                    <td>${st.addr}</td>
                    <td>
                    <a href="#" class="btn-primary btn-sm btn-success">修改</a>
                    <a href="#" class="btn-primary btn-sm btn-danger">删除</a>
                    </td>
                </tr>
                </c:forEach>
            </table>
<%--        查询表单--%>
        <form class="form-inline" style="float:left;" method="post" action="/student2/search.do">
<%--            学生姓名--%>
            <input type="hidden" name="page" id="page" value="${param.page}">
    <div class="form-group">
        <input type="text" class="form-control" id="sname" name="sname" value="${student.sname}" placeholder="学生姓名">
    </div>
<%--            学生住址--%>
    <div class="form-group">
        <input type="text" class="form-control" id="addr" name="addr" value="${student.addr}" placeholder="学生住址">
    </div>
<%--            学生班级--%>
    <div class="form-group">
        <select class="form-control" name="cid" id="cid">
            <option value="0">所在班级</option>
            <c:forEach items="${classes}" var="c">
                <option value="${c.cid}" ${c.cid==student.cid?'selected':''}>${c.cname}</option>
            </c:forEach>
        </select>
    </div>
    <button type="submit" class="btn btn-default btn-sm btn-primary">查询</button>
    <a href="/student2/edit.do" class="btn btn-default btn-sm btn-primary">添加</a>
        </form>
<%--        分页导航--%>
        <nav aria-label="Page navigation" style="text-align: right">
            <ul class="pagination">
                <li>
                    <a href="#" aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>
                <%--分页栏,开始为第一页,结束为分页的总页数--%>
                <c:forEach begin="1" end="${pr.totalPage}" var="p">
                    <%--点击数字时的跳转路径--%>
                    <li class="${p ==pr.page?'active':''}">
                        <a onclick="skinPage(${p})">${p}</a>
                    </li>
                </c:forEach>
                <li>
                    <a href="#" aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
            </ul>
        </nav>
        <div class="panel-body text-right">
            右下角
        </div>
    </div>
    </div>
</body>
</html>
